﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UMLTouch.Core.ViewModel;
using UMLTouch.Domain.ClassDiagram.Items;
using System.Windows;

namespace UMLTouch.Domain.ClassDiagram.ViewModels
{
    public class ClassDiagramContextViewModel : DiagramContextViewModel
    {

        public ClassDiagramContextViewModel(ClassDiagramContext diagramContext,DiagramItemsViewModelCollection col)
            :base(diagramContext,col)
        {

        }

        public ClassDiagramContextViewModel(ClassDiagramContext diagramContext)
            :this(diagramContext,new DiagramItemsViewModelCollection())
        {

        }

        public ClassDiagramContextViewModel(String name)
            :this(new ClassDiagramContext(name))
        {

        }

        public ClassDiagramContextViewModel()
            :this("Class Diagram")
        {

        }

        protected override DiagramItemViewModel CreateDiagramItemViewModel(UMLTouch.Core.UI.IDiagramItem item)
        {
            if (item is EntityItem)
            {
                return new EntityViewModel(item as EntityItem);

            }
            else if (item is RelationArrowItem)
            {
                return new RelationArrowViewModel(item as RelationArrowItem);
            }
            else
            {
                return new UnknownItemViewModel();
            }

           
           
        }


        protected override void _diagramItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            base._diagramItems_CollectionChanged(sender, e);
            Application.Current.Dispatcher.Invoke
                (new Action(() => 
                {
                    Strokes.Clear();
                }));
        }
    }
}
